﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using iTextSharp.text;
using iTextSharp.text.pdf;

namespace Test {
    public class pdf {
        public static void CreatePDF(string msg)
        {

            Document document = new Document();
            PdfPTable table = new PdfPTable(3);
            PdfPCell cell;

            cell = new PdfPCell(new Phrase("ID"));
            cell.Colspan = 3;
            cell.HorizontalAlignment = 1;

            table.AddCell(cell);

            table.AddCell("1,1");
            table.AddCell("1,2");
            table.AddCell("1,1");
            table.AddCell("1,2");
            table.AddCell("1,1");
            //table.AddCell("1,2");

            //Document document = new Document();
            string path = "E:\\Queue.pdf";//"Queue.pdf"
            FileStream fileStream = new FileStream(path,FileMode.Create);
            PdfWriter.GetInstance(document,fileStream);
            document.Open();
            ////设置中文是字体，否则，中文存不了
            //BaseFont bfHei = BaseFont.CreateFont(@"C:\Windows\Fonts\simfang.ttf",BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
            //iTextSharp.text.Font font = new Font(bfHei,16);
            document.Add(table);//msg你需要在PDF中显示的文字
            document.Close();
        }
    }
}
